package com.test.dao.impl;

import com.test.dao.IHouseValveCurrentDao;
import com.test.model.HouseValveCurrentData;
import org.hibernate.Query;
import org.hibernate.transform.Transformers;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * Created by ZZF on 2017/7/5.
 */
@Repository
public class HouseValveCurrentDaoImpl extends BaseDaoImpl<HouseValveCurrentData> implements IHouseValveCurrentDao {

    @Override
    public Map<String, Object>  findSwitchState(int houserMeterId) {

        String Sql="SELECT c.switchState AS switchState FROM rcc_d_housemetercurrentdata x " +
                "INNER JOIN  `rcc_e_housemeter` a ON x.houseMeterId=a.uniqueId " +
                "INNER JOIN rcc_e_housevalve b ON b.houseId=a.houseId " +
                "INNER JOIN rcc_d_housevalvecurrentdata c on c.houseValveId=b.uniqueId " +
                "WHERE x.houseMeterId="+houserMeterId;

        Query query = getSession().createSQLQuery(Sql).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);

        Map<String, Object> data = (Map<String, Object>) query.uniqueResult();

        return data;
    }
}
